﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using SGIMail.Models;

namespace SGIMail.DAL
{
    class ApplicationDBInitializer : System.Data.Entity.DropCreateDatabaseIfModelChanges<ApplicationDbContext>
    {

        protected override void Seed(ApplicationDbContext context)
        {
            var company = new List<Company>
            {
            
            new Company{CompanyName="PizzeriaAB"},
            new Company{CompanyName="KorvKioskAB"},
           
            
            
            };

            company.ForEach(c => context.Company.Add(c));
            context.SaveChanges();

            var contacts = new List<Contact>
            {
            
            new Contact{Name="Kalle",Email="kalle@test.se",CompanyId=1},
            new Contact{Name="Oskar",Email="oskar@test.se",CompanyId=2},
            new Contact{Name="Johan",Email="johan@test.se",CompanyId=1}
            };

            contacts.ForEach(c => context.Contacts.Add(c));
            context.SaveChanges();

            var events = new List<Event>
            {
            
            new Event{Name="event1",Theme=Themes.Cloud,ImagePath="https://ci3.googleusercontent.com/proxy/jdWcd44OGk9P091mo9I0ghl7m2oB8Aqo88hDBVhRyek4-q6hQKen9mbS7MRw2qHfocYs8i6DBmNCA20Z5nbfuBlC=s0-d-e1-ft#http://oakwood.se/clients/sogeti/sog1530.jpg",RegistrationURL="http://www.sogeti.se/sid13mars",Date=DateTime.Parse("2005-09-01")},
            new Event{Name="event2",Theme=Themes.Dynamics,ImagePath="https://ci3.googleusercontent.com/proxy/jdWcd44OGk9P091mo9I0ghl7m2oB8Aqo88hDBVhRyek4-q6hQKen9mbS7MRw2qHfocYs8i6DBmNCA20Z5nbfuBlC=s0-d-e1-ft#http://oakwood.se/clients/sogeti/sog1530.jpg",RegistrationURL="http://www.sogeti.se/sid13mars",Date=DateTime.Parse("2014-09-01")}
            
            
            
            };

            events.ForEach(e => context.Events.Add(e));
            context.SaveChanges();

            var eventdetails = new List<EventDetails> { 
            
            
            new EventDetails{Category= Category.Mailed,Date=DateTime.Parse("2014-08-01"),EventId=2,ContactId=1},
            new EventDetails{Category= Category.Registered,Date=DateTime.Parse("2005-08-01"),EventId=2,ContactId=2},
            
            
            };

            eventdetails.ForEach(e => context.EventDetails.Add(e));
            context.SaveChanges();

        }
    }
}
